﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="trueip.aspx.cs" Inherits="WebApplication1.IP地址和真实ip.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            本地ip：<asp:Label ID="Label1" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Text="Label"></asp:Label>
            <br />
            互联网ip：<asp:Label ID="Label2" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Text="Label"></asp:Label>
            <br />
            <br />
            ----<br />
            <br />
            本地ip：<asp:Label ID="Label3" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Text="Label"></asp:Label>
            <br />
            互联网ip：<asp:Label ID="Label4" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Text="Label"></asp:Label>
            <pre>
            Label1.Text = Request.ServerVariables["REMOTE_ADDR"];
            Label2.Text = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            Label3.Text = HttpContext.Current.Request.UserHostAddress;
            Label4.Text = HttpContext.Current.Request.ServerVariables.Get("Local_Addr").ToString();
            </pre>

        </div>
    </form>
</body>
</html>
